#pragma once
#include "log.hpp"
#include <unistd.h>
#include <stdlib.h>
#include <fcntl.h>

void SetNonBlock(int sock)
{
    int fl = fcntl(sock, F_GETFD);
    if (fl < 0) { 
        LOG(Error, "fcntl error!");
        exit(-1);
    }
    fcntl(sock, F_SETFL, fl | O_NONBLOCK);
}